# import urllib.request
# import io
# import xlsxwriter
#
#
# workbook = xlsxwriter.Workbook('images.xlsx')
# worksheet = workbook.add_worksheet()
# # 加宽第一列使文本更清晰。
# worksheet.set_column('A:A', 10)
# # 加宽图片列
#
# worksheet.set_column(1, 45)
# worksheet.set_default_row(45)
#
# worksheet.insert_image('A1', r'D:\Jim\网络红人的整理\u1\AKB22420001.jpg',{'x_scale': 0.1, 'y_scale': 0.07})
# worksheet.write('B1','12345')
# workbook.close()



import requests

def login():
    login_url = 'http://sw.eccang.com/default/index/login'
    headers = {
        # "Accept": "application/json, text/javascript, */*; q=0.01",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36",
        "Referer": "http://sw.eccang.com/default/index/logout?company_code=sw"
    }
    body = {
        "userName": "jinhuaitao",
        "userPass": "jht834719#",
        "companyCode":""
    }
    try:
        res = requests.post(url=login_url, data=body)
        cookies = res.cookies.items()
        print(cookies)
        cookie = ''
        for name, value in cookies:
            cookie += '{0}={1};'.format(name, value)
        print(cookie)
        return cookie
    except Exception as err:
        print('获取cookie失败：\n{0}'.format(err))

login()